<?php

namespace App\Api;

use PhalApi\Api;


/**
 * 后台专用接口
 *
 * @author: dogstar <chanzonghuang@gmail.com> 2014-10-04
 */
class WeChatipadSend extends Api
{

    public function getRules()
    {
        return array(
            'sendText' => array(
                "content" => array('name'=>'content'),
                "wxId" => array('name'=>'wxId'),
            ),
        );
    }

    /**
     *  发送文字
     *  @url sendText
     *  @return array 
     *  @throws    
     *  @author dogstar <wenhong520@qq.com> 2014-10-04
     */
    public function sendText()
    {
        //这里是提示的开始
        $curl = new \PhalApi\CUrl();
        // 设置请求的头部信息。
        $curl->setHeader(array('Authorization' => 'd303cfaf89a00155aff1fcd4a96a0348'));
        // 设置curl选项
        $postDate = array(
            "deviceId" => "wx001",
            "wxId" => $this->wxId,
            "content" => $this->content,
        );

        $url = "http://14.116.199.151:3003/open/sendText";
        $res = $curl->post($url, $postDate, 3000);
        $res = json_decode($res, true);
        $res['deviceId'] = $postDate['deviceId'];
        return $res;
    }
    
    /**
     *  确认登录
     *  @url checkLogin
     *  @return array 
     *  @throws    
     *  @author dogstar <wenhong520@qq.com> 2014-10-04
     */
    public function checkLogin()
    {
        //这里是提示的开始
        $curl = new \PhalApi\CUrl();
        // 设置请求的头部信息。
        $curl->setHeader(array('Authorization' => 'd303cfaf89a00155aff1fcd4a96a0348'));
        // 设置curl选项
        $postDate = array(
            "deviceId" => "wx001",
        );

        $url = "http://14.116.199.151:3003/open/checkLogin";
        $res = $curl->post($url, $postDate, 3000);
        $res = json_decode($res, true);
        $res['deviceId'] = $postDate['deviceId'];
        return $res;
    }

    /**
     *  生成码
     *  @url checkLogin
     *  @return array 
     *  @throws    
     *  @author dogstar <wenhong520@qq.com> 2014-10-04
     */
    public function getLoginQrCode()
    {
        //这里是提示的开始
        $curl = new \PhalApi\CUrl();
        // 设置请求的头部信息。
        $curl->setHeader(array('Authorization' => 'd303cfaf89a00155aff1fcd4a96a0348'));
        // 设置curl选项
        $postDate = array(
            "deviceId" => "wx001",
            "province" => "杭州",
        );

        $url = "http://14.116.199.151:3003/open/getLoginQrCode";
        $res = $curl->post($url, $postDate, 3000);
        $res = json_decode($res, true);
        $res['deviceId'] = $postDate['deviceId'];
        return $res;
    }
    
    /**
     *  设备
     *  @url workstation
     *  @return array 
     *  @throws    
     *  @author dogstar <wenhong520@qq.com> 2014-10-04
     */
    public function workstation()
    {
        //这里是提示的开始
        $curl = new \PhalApi\CUrl();
        // 设置请求的头部信息。
        $curl->setHeader(array('Authorization' => 'd303cfaf89a00155aff1fcd4a96a0348'));
        // 设置curl选项
        $postDate = array(
            "deviceId" => "wx001",
        );

        $url = "http://14.116.199.151:3003/open/workstation";
        $res = $curl->post($url, $postDate, 3000);
        $res = json_decode($res, true);
        $res['deviceId'] = $postDate['deviceId'];
        return $res;
    }

    /**
     *  登录
     *  @url GET /login/
     *  @return array 
     *  @throws    
     *  @author dogstar <wenhong520@qq.com> 2014-10-04
     */
    public function login()
    {
        //这里是提示的开始
        $curl = new \PhalApi\CUrl();
        // 设置请求的头部信息。
        // $curl->setHeader(array('Content-Type' => 'application/x-www-form-urlencoded'));
        // 设置curl选项
        $postDate = array(
            "username" => "18128823268",
            "password" => "20231215",
        );

        $url = "http://14.116.199.151:3003/auth/login";
        $res = $curl->post($url, $postDate, 3000);
        return json_decode($res);
    }
    

}
